﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BOMS.DAL;
using System.Web.Security;
using BOMS.Utility;
namespace BOMS.WebUI
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void loginBtn_Click(object sender, ImageClickEventArgs e)
        {
            string userName = this.userName.Text;
            string pwd = this.pwd.Text;

            string userid;
            Boolean IsCheck = SysAdmin.LoginCheck(userName, pwd, out userid);

            //用户账号校验
            if (!IsCheck)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ADTHORERROR", "alert('用户名或者密码不正确！');", true);
                return;
            }

            FormsAuthentication.SetAuthCookie(userid, true);
            HttpContext.Current.User = new FormsPrincipal(userid);

            if (fullscreen.Checked)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "info", "<script language=\"javascript\">winopen();</script>");
            }
            else
            {
                if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
                {
                    Response.Redirect(Request.QueryString["ReturnUrl"]);
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
            }
        }
    }
}